home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
ansi
/
useansi.zip
/
USEANSI.TXT
< prev
Wrap
Text File
|
1985-09-08
|
16KB
|
435 lines
───────────────────────────────────────────────────────────────────────────────
USING THE ANSI DRIVER
by
C. Scot Giles
875 Lake Street
Oak Park, Illinois 60301
This essay is an attempt to explain how I use the ANSI.SYS driver to configure
the function keys on my computer, and to control the screen. I have used
these techniques on my PC and AT for years, and find them to be convenient and
effective. ANSI is not widely used by microcomputer fans because the
documentation supplied by IBM on how to send control codes to the ANSI driver
is among the most cryptic ever produced by IBM. I learned them by reading
computer magazines, and slowly figured out how it could be done. I am not a
professional computer programmer (indeed I am a clergyman), so some of my
technical observations might be in error. But everything here works, and I
have retested it before finishing this essay.
This essay covers only IBM Personal Computers (PC, XT or AT) running DOS 2.n
or greater. I have no experience with compatibles, so you are on your own if
you try to use these techniques on one.
LOADING THE ANSI DRIVER
In order to use any of the techniques in this essay, you must first have
loaded the ANSI.SYS driver into your computer's memory using your CONFIG.SYS
file. You do this my adding the line, DEVICE=ANSI.SYS somewhere in the
CONFIG.SYS file and rebooting your computer.
KEYBOARD REASSIGNMENT WITH ANSI
Before we get to specific ways to send control codes to the (now loaded) ANSI
driver, you must first know what those codes mean. For the function keys the
codes are listed on the chart below which first appeared in SOFTALK magazine.
Each function key is assigned an "extended function code" which DOS will use
to recognize that a function key has been pressed and in what shifted mode, if
any. Each number is expressed as a 0 followed by a semi-colon, then the
number from the chart below.
KEY NORMAL SHIFT CONTROL ALT
F1 59 84 94 104
F2 60 85 95 105
F3 61 86 96 106
F4 62 87 97 107
F5 63 88 98 108
F6 64 89 99 109
F7 65 90 100 110
F8 66 91 101 111
F9 67 92 102 112
F10 68 93 103 113
Accordingly, the way to designate the F5 key would be 0;63 while the F10 key
would be designated by 0;68 or 0;113 if shifted with the ALT key.
───────────────────────────────────────────────────────────────────────────────
Using the ANSI driver, Page -2-
If you examine the DOS Technical Reference Manual (not the Technical Manual
for PC hardware), you will find a section on SCREEN/KEYS. This section was
contained in the DOS 2.0 documentation, but IBM removed it in later editions.
Here is a summary of its contents relative to keyboard redefinition.
To change one key to have the meaning of another, enter:
ESC [#;#p
where the first # is the ASCII value of the key being changed and the second #
is the ASCII value of the new definition. For example, "A" has the ASCII
value of 65 and "Q" has the value of 81. So:
ESC [65;81p
will result in "A" being redefined as "Q." It is also possible to redefine a
key to have the meaning of a string of characters. This is done by enclosing
the string in quotes. So:
ESC [65;"Hi there"p
would change the "A" key to have the meaning of "Hi there." If the first
value for the first # is a 0 however, DOS knows that what is being changed is
not an ASCII value but the meaning of an extended function code. So if you
were to enter:
ESC [0;68;"Hi there"p
DOS would know to change the meaning of the function key (in this case F10) to
the sting enclosed in quotes. This is the key to redefining your function
keys to perform much used commands: like DIR, CHKDSK, COPY *.* B: etc. or to
load programs from disk.
There is a final trick here. If you end the escape command sequence with the
characters ";13p" instead of just "p" the command will self-execute, just as
if you pressed the [enter] key.
The IBM documentation tells the user to preface each command by an ESC
command, and I have represented this in the above paragraphs by writing the
characters "ESC." at the start of each control code sequence mentioned. Most
users assume that this means to press the ESC key on the keyboard when
entering the commands. Not so. To get the Escape Sequence to the ANSI driver
you must enter it using a prompt command or write a .COM file. For example to
configure the F1 key (extended function code 59) to have the meaning in DOS of
"autoexec" with an [enter] command at the end of it you cannot type:
ESC [0;59;"autoexec";13p
as the ESC will not be recognized by DOS as an escape sequence. What DOS will
recognize as an escape sequence is the characters "$e" although this surely
looks strange at first. Users familiar with the PROMPT command will notice
that the "$" character is what the PROMPT command uses as an escape sequence,
and that is precisely how we will get the redefinition to be recognized by
DOS. If you enter the following command:
───────────────────────────────────────────────────────────────────────────────
Using the ANSI driver, Page -3-
PROMPT $e[0;59;"autoexec";13p
you will see that it works perfectly. You now have the secret to redefining
the function keys in DOS. Simply write and run a batch file with a list of
PROMPT commands and you will have done it. One precaution, ECHO must be ON,
otherwise DOS will suppress the PROMPT command and the escape sequences will
not get through.
As an example, let's create a batch file called KEYON.BAT that will set F1 as
EDITOR [enter], F2 as PC-FILE [enter], F3 as PC-CALC [enter], F4 as PC-GRAPH
[enter], F5 as PC-TALK [enter], F6 as PC-WRITE [enter], F7 as BASICA [enter],
F8 as DIR without the [enter], F9 to run a batch file called MENUOFF.BAT
[enter] and F10 to run a batch file called MENUON.BAT [enter]. It would be as
follows:
echo on
PROMPT $e[0;59;"EDITOR";13p
PROMPT $e[0;60;"PC-FILE";13p
PROMPT $e[0;61;"PC-CALC";13p
PROMPT $e[0;62;"PC-GRAPH";13p
PROMPT $e[0;63;"PC-TALK";13p
PROMPT $e[0;64;"PC-WRITE";13p
PROMPT $e[0;65;"BASICA";13p
PROMPT $e[0;66;"DIR"p
PROMPT $e[0;67;"MENUOFF";13p
PROMPT $e[0;68;"MENUON";13p
prompt
cls
You would also want to create another file called KEYOFF.BAT which resets the
function key definitions to DOS normal. The format would be:
echo on
PROMPT $e[0;59;0;59p
PROMPT $e[0;60;0;60p
PROMPT $e[0;61;0;61p
PROMPT $e[0;62;0;62p
PROMPT $e[0;63;0;63p
PROMPT $e[0;64;0;64p
PROMPT $e[0;65;0;65p
PROMPT $e[0;66;0;66p
PROMPT $e[0;67;0;67p
PROMPT $e[0;68;0;68p
prompt
cls
I should mention that the purpose of the final blank PROMPT command in each of
these batch files is to reset the DOS prompt to A> or whatever your default
prompt is. It serves no redefinition purpose, but does keep the screen
looking clean.
────────────────────